import java.util.Arrays;
class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode(int x) { val = x; }
}
public class project {
    public int[] xorQueries(int[] arr, int[][] queries) {
        int[] ret=new int[queries.length];
        for(int i=0;i<queries.length;i++){
            int x=queries[i][0];
            int y=queries[i][1];
            for(int j=x;j<=y;j++){
                ret[i]^=arr[j];
            }
        }
        return ret;
    }




















    public boolean checkSubTree(TreeNode t1, TreeNode t2) {
        if(t1==null){
            return false;
        }
        if(t2==null){
            return true;
        }
        return dfs(t1,t2)||checkSubTree(t1.left,t2)||checkSubTree(t1.right,t2);
    }
    public boolean dfs(TreeNode t1,TreeNode t2){
        if(t1==t2){
            return true;
        }
        if(t1==null||t2==null){
            return false;
        }
        return t1.val==t2.val&&dfs(t1.left,t2.left)&&dfs(t1.right,t2.right);
    }



















    public int findFinalValue(int[] nums, int original) {
        boolean bool=false;
        while (true){
            bool=false;
            for(int i=0;i<nums.length;i++){
                if(nums[i]==original){
                    original*=2;
                    bool=true;
                    break;
                }
            }
            if(!bool){
                break;
            }
        }
        return original;
    }
















    public int minimumSum(int num) {
        int[] arr=new int[4];
        int i=0;
        while (num!=0){
            arr[i++]=num%10;
            num/=10;
        }
        Arrays.sort(arr);
        return arr[0]*10+arr[2]+arr[1]*10+arr[3];
    }
}
